package com.jl.jlapp.popu;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter.OnItemClickListener;
import com.jl.jlapp.R;
import com.jl.jlapp.adapter.ChooseSendToAddressAdapter;
import com.jl.jlapp.eneity.ShipAddressModel;
import com.jl.jlapp.eneity.ShipAddressModel.ResultDataBean;
import com.jl.jlapp.utils.CustomLanearLayoutManager;

import java.util.List;

import static android.content.Context.LAYOUT_INFLATER_SERVICE;

public class ChooseSendToAddressPopu
        extends PopupWindow {
    List<String> address;
    TextView chooseAddressBottomBtn;
    RelativeLayout chooseAddressPopup;
    ChooseSendToAddressAdapter chooseSendToAddressAdapter;
    RecyclerView chooseSendToAddressRecyclerView;
    ImageView closeBtn;
    private OnClickItem onClickItem;
    String saveChooseAddress = "";
    private setOnClickBottomOKBtn setOnClickBottomOKBtn;
    private TextView shadowPart;
    private View view;

    public ChooseSendToAddressPopu(Context paramContext, String paramString, List<ShipAddressModel.ResultDataBean> paramList) {
        super(paramContext);
        this.saveChooseAddress = paramString;
        this.view = ((LayoutInflater) paramContext.getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(R.layout.choose_send_to_address_pop, null);
        this.shadowPart = ((TextView) this.view.findViewById(R.id.shadow_part));
        this.chooseSendToAddressRecyclerView = ((RecyclerView) this.view.findViewById(R.id.choose_send_to_address_recycler_view));
        this.chooseAddressPopup = ((RelativeLayout) this.view.findViewById(R.id.choose_address_popup));
        this.chooseAddressBottomBtn = ((TextView) this.view.findViewById(R.id.choose_address_bottom_btn));
        this.closeBtn = ((ImageView) this.view.findViewById(R.id.close_btn));
        this.chooseSendToAddressRecyclerView.setLayoutManager(new CustomLanearLayoutManager(paramContext, false));
        this.chooseSendToAddressAdapter = new ChooseSendToAddressAdapter(R.layout.choose_send_to_address_item, paramList);
        this.chooseSendToAddressAdapter.setChooseAddress(this.saveChooseAddress);
        this.chooseSendToAddressRecyclerView.setAdapter(this.chooseSendToAddressAdapter);
        this.chooseSendToAddressAdapter.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(BaseQuickAdapter paramAnonymousBaseQuickAdapter, View paramAnonymousView, int paramAnonymousInt) {
                TextView textView = (TextView) paramAnonymousView.findViewById(R.id.choose_address_location);
                if (("".equals(ChooseSendToAddressPopu.this.saveChooseAddress)) || (!ChooseSendToAddressPopu.this.saveChooseAddress.equals(textView.getText().toString().trim()))) {
                    ChooseSendToAddressPopu.this.saveChooseAddress = textView.getText().toString().trim();
                    ChooseSendToAddressPopu.this.chooseSendToAddressAdapter.setChooseAddress(ChooseSendToAddressPopu.this.saveChooseAddress);
                    ChooseSendToAddressPopu.this.chooseSendToAddressAdapter.notifyDataSetChanged();
                }
                if (ChooseSendToAddressPopu.this.onClickItem != null) {
                    ChooseSendToAddressPopu.this.onClickItem.onClickItem(ChooseSendToAddressPopu.this.saveChooseAddress);
                }
            }
        });
        setContentView(this.view);
        setWidth(-1);
        setHeight(-1);
        setFocusable(true);
        setAnimationStyle(R.style.AnimBottom);
        setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(paramContext,R.color.white)));
        this.view.setOnTouchListener(new OnTouchListener() {
            public boolean onTouch(View paramAnonymousView, MotionEvent paramAnonymousMotionEvent) {
                int i = ChooseSendToAddressPopu.this.chooseAddressPopup.getTop();
                int j = (int) paramAnonymousMotionEvent.getY();
                if ((paramAnonymousMotionEvent.getAction() == 1) && (j < i)) {
                    ChooseSendToAddressPopu.this.dismiss();
                }
                return true;
            }
        });
        this.chooseAddressBottomBtn.setOnClickListener(new OnClickListener() {
            public void onClick(View paramAnonymousView) {
                if (ChooseSendToAddressPopu.this.setOnClickBottomOKBtn != null) {
                    ChooseSendToAddressPopu.this.setOnClickBottomOKBtn.onClickBottomOkBtn();
                }
            }
        });
        this.closeBtn.setOnClickListener(new OnClickListener() {
            public void onClick(View paramAnonymousView) {
                ChooseSendToAddressPopu.this.dismiss();
            }
        });
    }

    public void setOnClickItem(OnClickItem paramOnClickItem) {
        this.onClickItem = paramOnClickItem;
    }

    public void setSetOnClickBottomOKBtn(setOnClickBottomOKBtn paramsetOnClickBottomOKBtn) {
        this.setOnClickBottomOKBtn = paramsetOnClickBottomOKBtn;
    }

    public static abstract interface OnClickItem {
        public abstract void onClickItem(String paramString);
    }

    public static abstract interface setOnClickBottomOKBtn {
        public abstract void onClickBottomOkBtn();
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/popu/ChooseSendToAddressPopu.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */